package com.rocketmq.producer.controller;

import com.rocketmq.producer.model.MseeageEntity;
import com.rocketmq.producer.service.MqService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import javax.annotation.PostConstruct;

/**
 * @Description:
 * @author: zhengfei
 * @param:
 * @date: 2018-06-22 下午6:05
 */

@Controller
public class ReqController {

    @Autowired
    private MqService mqService;

    @PostConstruct
    public void init(){
        for(int j = 1 ; j <= 20 ; j ++){
            int finalJ = j;
            Runnable runnable = new Runnable() {
                @Override
                public void run() {
                    msg(finalJ);
                }
            };
            Thread thread=new Thread(runnable);
            thread.start();
        }
    }

    private void msg(int j){
        int i = 0;
        while (i < 10000000){
            mqService.sendMsq(MseeageEntity.builder().id( j +""+ i).build());
            i ++ ;
        }
    }
}
